<template>
  <div>
    <el-table :data="tableData" border style="width: 100%">
      <el-table-column
        prop="id"
        label="编号"
        width="80">
      </el-table-column>
      <el-table-column
        prop="name"
        label="姓名"
        width="100">
      </el-table-column>
      <el-table-column
        prop="phone"
        label="电话"
        width="180">
      </el-table-column>
      <el-table-column
        prop="email"
        label="邮箱">
      </el-table-column>
      <el-table-column
        prop="address"
        label="地址">
      </el-table-column>
      <el-table-column
        prop="createTime"
        label="创建时间">
      </el-table-column>

      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button
            size="mini"
            icon="el-icon-edit-outline"
            @click="handleEdit(scope.row)">编辑</el-button>
          <el-button
            size="mini"
            type="danger"
            icon="el-icon-delete"
            @click="handleDelete( scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      background
      layout="total, prev, pager, next, jumper"
      @current-change="queryPage"
      :total="totals"
      :current-page="currentPage"
      :page-size="pageSize">
    </el-pagination>
  </div>
</template>

<script>
export default {
  data () {
    return {
      pageSize:5,
      currentPage:1,
      totals:0,
      tableData: []
    }
  },
  methods:{
    queryPage(page){
      //给当前页赋值
      this.currentPage=page;
      //查询新的数据
      this.getStus();
    },
    handleEdit(row){
    },
    handleDelete(row){
    },
    getStus(){
      this.$http.post("/stu/list",{"currentPage":this.currentPage,"pageSize":this.pageSize}).then((result) =>{
        console.debug(result);
        //成功之后给数组赋值
        this.tableData = result.data.data;
        this.totals = result.data.totals;
      }).catch((result)=>{
      })
    }
  },
  mounted() {
    this.getStus();
  }
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style>

</style>
